Documents | Main / Table of Contents

Reports and Analysis

Purpose

Report Classes and their Reports:

Reports 107 to 113 do not have Destination to Excel available.

Procedure

  • If the EMail Report option is chosen, make sure the real_name field in the users table for the logged in user is filled. Otherwise the sender's name will be blank.
  • Linking Reports. reporting/includes/reporting.inc line 128, function print_link() shows how to make a link to the core report you want and manufacturing/workorder_entry.php line 64 shows how to build a report link.

Report Extensions

Watermarking

Yes, indeed, there is possibility to insert watermark, or even whole externally designed blueprint in documents generated in NotrinosERP.

The blueprint have to be designed as PDF-1.4 file (other pdf formats may also be supported), and you will have to put the designed watermark page in /reporting/forms folder.

Out of the box two blueprints are supported for two basic document layouts:

  • Header2.pdf - for reports 107-113, 209,210 and 409
  • Header.pdf - for all other documents

If you want to test this feature, just put attached file in the forms folder and generate Sales Invoice. In real design some small changes in repxxx.php files can be necessary.

Of course this feature does not address directly the problem of ad-hoc per document watermarks, but is ready to use if e.g. you plan to hire artist to design your invoices ;).

EMailing parameters in Batch Files

The links like the following can be used in batch files to email reports:

http://example.com/fa/reporting/prn_redirect.php?PARAM_0=1-10&PARAM_1=1-10&PARAM_2=&PARAM_3=1&PARAM_4=&PARAM_5=&PARAM_6=&PARAM_7=0&REP_ID=107

or just the parameters needed like:

http://example.com/reporting/prn_redirect.php?PARAM_0=1-10&PARAM_1=1-10&PARAM_3=1&PARAM_7=0&REP_ID=107

The following reports in FA can be emailed directly from the reports page form choices:

email_Customers

  • 107 - Invoices (From 0, To 1, EMail 3)
  • 113 - Credit Notes
  • 110 - Deliveries
  • 108 - Statements
  • 109 - Sales Orders
  • 111 - Sales Quotations
  • 112 - Receipts

Email Suppliers

  • 209 - Purchase Orders
  • 210 - Remittances

EMail Locations

  • 409 - Work Orders

Watermarking and background / logo merging in reports

  • Another page on Watermarking circa 2013.
  • Per company, per Template report woatermarking is available in NotrinosERP.
  • Background / Watermark merge PDF file for Company # to be located in the folder: company/#/reporting/forms
  • The merge PDF file should be of Acrobat Reader format v5.0 (PDF format v1.4) or lower since FA uses the free FPDI v1.2.1 library released on 2008-09-11
  • Sample OpenWriter Watermark/logo file for customization is here courtesy Joe Hunt.
  • Watermark / logo PDFs can be created in MS Word 2007 => Page Layout => Watermark => Custom Watermark => File => Save As => PDF or XPS are of PDF Format v1.5 and above and needs to be printed in some virtual printer like PDFCreator or doPDF. PDFCreator generates small PDF files and is free but may try to install some nagware (optional) in the later versions.
  • Choosing standard fonts like Arial will result in non embedding of fonts in the resultant PDF making it small in size.
  • On New page creation in reports, the function setSourceFile() in reporting/includes/fpdi/fpdi.php is called and returns the number of pages in the above Header2.pdf file.
  • On New page creation in reports another possibility is to place a Header2.php file in reporting/forms folder (possibly in the company folder) as well.
  • If the Header2.pdf / Header.pdf files have more than one page, then each one is used in succession for the report and the last one is used for the remaining pages of the report.
  • Use Cases:
    • Company logo at the top of the Header.pdf.
    • Stamp underneath the existing report, such as confidential data across the page in a vague / subdued color.
    • setSourceFile() loads an existing pdf as a "background", onto which all output is "printed".
    • Incorporate a company letterhead.

Header2.php file in Watermarking and background of reports

  • The Template (eg., Header2) function is executed only at the very end of the NewPage() method in reporting/includes/pdf_report.inc.
  • The company/#/reporting/Header2.php if present will provide overrides for properties not defined in
    • the Newpage() method
    • doctext.inc
    • header2.inc
  • It will also provide values in cases where pre-defined properties in the above are not overridden (like $this->formData['br_name']).
  • Any variables (need to global them) and properties referred to in the header2.inc and doctext.inc files that are not part of the core can be provided in the Header2.php file and assigned in header2.inc and doctext.inc only if absent.
  • Example of Header2.php usage and it's effect is here.
  • The mere presence of the file company/#/reporting/includes/header2.inc does not ensure that it will be used in reports. It is necessary for the appropriate company/#/reporting/repXXX.php file to be present for it to apply to it.

Tips and Tricks

RTL Fonts

Suppressing Page number display

  • Comment out the lines 144-147 in reporting/includes/header2.inc
//        $this->NewLine(2);
//    
//        if ($this->pageNumber > 1)
//            $this->Text($mcol + 180, _("Page") . ' ' . $this->pageNumber);

PDF Failure

  • Symptom: PDF reports has stopped working, reports to Excel/LibreOffice works.
  • Fix: On some newer internet explorer releases, you will have to set the compatibility mode. If you cannot solve this you may use another browser like Firefox or another.
  • Fix: On recent Firefox browsers, the PDF Application Viewer is set to internal preview pdfjs feature that does not yet have full Adobe PDF functionality. View Article.
  • Fix: The php.ini setting of the variable max_input_vars may be increased from the default value of 1000 (even if not present in some php versions).

dejavu.php missing - TCPDF Font Failure

  • Download dejavu.zip
  • Extract contents to reporting/fonts folder
  • This is the default unicode font when none are defined
  • Can change this font at around line 161 in reporting/includes/class.pdf.inc

Charge To / deliver To

  • Create customer: Mark
  • Create branch DD Towing under customer Mark
  • Sales quote or Order pdf will display DD Towing in Charge to and Deliver to field
  • This was changed to make possible having branches charged directly
  • To revert to old FA v2.3.6 functionality, set the name and billing address for the branch the same as for customer (keep branch short name unique to easily recognise branches in selectors). If this is still a problem (e.g. you have big database with mostly multibranch customers) you can fix the charge data in reporting/includes/doctext.inc file about line 18-20 (the code should be self explanatory). Lines 44 and 61 can be changed from
_("Customer's Reference") => $this->formData["customer_ref"],

to

_("Customer's Reference") => $this->formData["name"],
  • If there is no Branch billing address, then the Customer address is used.

Report Signature

Do one of the following:

  • In Comment or Memo field
  • If this info is for all customers - add signature in the file reporting/includes/header2.inc
  • For only SALES QUOTATIONS, add the info in the file reporting/rep111.php.
if ($this->formData['doctype'] == ST_SALESQUOTE)
{
    $txt = "test";
    $this->TextWrapLines($ccol, $this->row, $right - $ccol, $txt, 'C')
}

Extra Message Lines in Delivery Note Report]]

Insert the following lines after line 216 in file reporting/rep110.php.

$rep->NewLine(2);
$rep->TextCol(1, 4, "_______________________________________________", -2);
$rep->NewLine(1);
$rep->TextCol(1,4, "      Signature, Company Stamp & Date", -2);

You may need to adjust the underline and text a bit. Try it on the Training Co. first. Please make a backup of the file, in case you get an update. You will then have to insert these lines again.

Extra Parameters in Reports taken from formatted notes field

Include the following function into any report or it's includes:

/*
// Purpose: Function to parse a string into parameters
// Release Date: 2014-12-26
// Author: ApMuthu <apmuthu@usa.net>
// Usage:
$str = "PPFrt#2000 CID#6378465 TaxEx#2345-038 abcde ertrgdert COD#4253 jdegtd PIN#6473654";
$p = parse_notes_params($str);
echo print_r($p, true);
*/

function parse_notes_params($str, $sep=" ", $delim="#") {
	$str_params = explode($sep, $str);
	$param_array=Array('notes' => '');
	foreach ($str_params AS $str_param) {
		$param_set=explode($delim, trim($str_param));
		$key = (array_key_exists(0, $param_set) ? trim($param_set[0]) : '');
		$val = (array_key_exists(1, $param_set) ? trim($param_set[1]) : '');
		if (strlen($key) > 0 && strlen($val) > 0) {
			$param_array[$key]=$val;
		} else {
			// stop at first missing parameter set
			// break;
			// Collect the rest into notes
			$param_array['notes'] .= (" " .  $str_param);
		}
	}
	$param_array['notes'] = trim($param_array['notes']);
	return $param_array;
}

An example of usage will be in the reporting/rep110.php file at near the end just before the last $rep-Font(); statement:

    $notes_params = parse_notes_params($branch['notes']);
    if ($packing_slip == 0 && array_key_exists('CID', $notes_params)) {
        $rep->NewLine(1);
        $rep->TextCol(1, 7, "Old Customer# : " . $notes_params['CID'], - 2);
    }

Screenshot

PDF Page Numbering

Site-wide report page numbering (useful particularly for multi page invoices) can be enabled by commenting out line 142 in reporting/includes/header2.inc:

//		if ($this->pageNumber > 1 && !strstr($this->filename, "Bulk"))

EMail Templating

Change line 1006 in reporting/includes/pdf_report.inc:

    $msg = _("Dear") . " " . $contact['name2'] . ",\n\n" 

to

    $msg = _("Dear") . " " . $contact['name'].' '.$contact['name2'] . ",\n\n" 

PDF Font Change

  • Put the 3 font files in reporting/fonts : tuffy.php, tuffy.z and tuffy.afm
  • On Linux
apt-get install ttf-tuffy
ln -s /usr/share/fonts/truetype/ttf-tuffy/* reporting/fonts
  • Edit reporting/includes/class.pdf.inc around Line 119:
// Was helvetica, now tuffy.
        $this->FontFamily = 'tuffy';
        $this->FontStyle = '';
        $this->FontSizePt = 12;

Add Page to Report

  • Example to add a page to rep109.php (Sales Order Report), say Tax Invoice not yet made:
// START my modification
$rep->SetHeaderType('');
$rep->NewPage();
/*
here i want to write predefined html report here 
*/
// END my modification

if ($ email == 1)
  {
    $ rep-> End ($ email);
  }
}
if ($ email == 0)
  $ rep-> End ();

When there are multiple users of a single role like Administrator, we track their individual actions (like who entered an order or who received cash) by using the Audit Trail report.

Old PDF Reports auto deletion time / retention

  • Raise the time from 3 minutes (180 secs) to a different value before a report is considered stale and deleted
  • Comment out the lines below to prevent it's deletion and retain it indefinitely.

Lines 1082-1085 in reporting/includes/pdf_report.inc:

// seems 3 min is enough for any report download, isn't it?
if (time()-$ftime > 180){
	unlink($dir.'/'.$file);
}